//app.js
import Auth from 'services/Auth'
import HttpService from 'services/HttpService'
import ApiUrl from 'services/ApiUrl'
import Util from 'services/Util'
App({
  onLaunch: function () {
    //调用API从本地缓存中获取数据
    // var logs = wx.getStorageSync('logs') || []
    // logs.unshift(Date.now())
    // wx.setStorageSync('logs', logs)
    Auth.login();
  },
  getUserInfo:function(){
        let self = this;
        let opts = {
            apiObj: ApiUrl.user
        }
        HttpService.accessAPI(opts).then(function(result){
            console.log( 'get profile success', result.data );
            if(result.data.member && typeof result.data.member == 'object'){
                result.data.member.gender = result.data.member.gender == 'male'?'男': '女';
                result.data.member.avatar = result.data.member.avatar? result.data.member.avatar+'?imageView2/1/w/200/h/200':'/images/avatar-placeholder.jpeg';
                result.data.member.birthday = Util.unixToDate(result.data.member.birthday);
            }
            wx.setStorage( { key:'profile', data: result.data } );
        })
   },
  globalData:{

  }
});